<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('完善项目信息')" />
</head>
<body>
<div class="ibox-content">
  <div class="nav-tabs-custom">
    <ul class="nav nav-tabs">
      <li class="active"><a th:href="@{'/project/projectInfo/edit/'+${projectId}}" aria-expanded="true">基本信息</a></li>
      <li><a th:href="@{'/project/projectFlow/edit/'+${projectId}}" aria-expanded="false">工艺处理流程</a></li>
      <li><a th:href="@{'/project/projectFlowParam/'+${projectId}}" aria-expanded="false">工艺处理流程参数</a></li>
      <li><a th:href="@{'/project/projectTech/edit/'+${projectId}}" aria-expanded="false">工艺运行情况</a></li>
      <li><a th:href="@{'/project/projectEqp/edit/'+${projectId}}" aria-expanded="false">设备运行情况</a></li>
      <li><a th:href="@{'/project/projectWater/edit/'+${projectId}}" aria-expanded="false">水质指标情况</a></li>
      <li><a th:href="@{'/project/projectMicro/edit/'+${projectId}}" aria-expanded="false">菌剂使用情况</a></li>
      <li><a th:href="@{'/project/projectPharm/edit/'+${projectId}}" aria-expanded="false">药剂使用情况</a></li>
    </ul>
    <div class="tab-content">
      <div class="tab-pane active">
        <form class="form-horizontal m" id="form-projectInfo-edit" th:object="${projectInfo}">
          <input id="projectId" name="projectId" th:field="*{projectId}"  type="hidden">
          <input name="deptId" type="hidden" id="treeId"/>
          <div class="row">
            <div class="col-sm-12">
              <div class="form-group">
                <label class="col-sm-3 control-label"><span style="color: red; ">*</span>客户名称：</label>
                <div class="col-sm-8">
                  <div class="input-group">
                    <input name="deptName" type="text" onclick="selectDeptTree()" id="treeName" th:field="*{deptName}" class="form-control" readonly="readonly" required>
                    <span class="input-group-addon"><i class="fa fa-search"></i></span>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="row">
            <div class="col-sm-12">
              <div class="form-group">
                <label class="col-sm-3 control-label"><span style="color: red; ">*</span>项目名称：</label>
                <div class="col-sm-8">
                  <input name="projectName" type="text" th:field="*{projectName}" class="form-control" maxlength="50" required>
                </div>
              </div>
            </div>
          </div>
          <div class="row">
            <div class="col-sm-12">
              <div class="form-group">
                <label class="col-sm-3 control-label"><span style="color: red; ">*</span>项目所在地：</label>
                <div class="col-sm-9">
                  <div class="form-group" th:inline="javascript">
                    <div data-toggle="distpicker">
                      <div class="col-xs-3"><select class="form-control" th:attr="data-province=${projectInfo.provinceName}" name="province_id" id="province_id" required></select></div>
                      <div class="col-xs-3"><select class="form-control" th:attr="data-city=${projectInfo.cityName}" name="city_id" id="city_id" required></select></div>
                      <div class="col-xs-3"><select class="form-control" th:attr="data-district=${projectInfo.zoneName}" name="zone_id" id="zone_id" required></select></div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="row">
            <div class="col-sm-12">
              <div class="form-group">
                <label class="col-sm-3 control-label"><span style="color: red; ">*</span>详细地址：</label>
                <div class="col-sm-8">
                  <input id="address" name="address" class="form-control" th:field="*{address}" type="text" maxlength="100" required>
                </div>
              </div>
            </div>
          </div>
          <div class="row">
            <div class="col-sm-12">
              <div class="form-group">
                <label class="col-sm-3 control-label"><span style="color: red; ">*</span>污水所属行业：</label>
                <div class="col-sm-8">
                  <select name="sewageType" class="form-control m-b" th:with="type=${@dict.getType('sewage_type')}" required>
                    <option value="">--请选择--</option>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:field="*{sewageType}" th:value="${dict.dictValue}"></option>
                  </select>
                </div>
              </div>
            </div>
          </div>
          <div class="row">
            <div class="col-sm-12">
              <div class="form-group">
                <label class="col-sm-3 control-label"><span style="color: red; ">*</span>设计进水量（t/d）：</label>
                <div class="col-sm-8">
                  <input name="designIntake" class="form-control" th:field="*{designIntake}" type="text" maxlength="8" required>
                </div>
              </div>
            </div>
            <div class="col-sm-12">
              <div class="form-group">
                <label class="col-sm-3 control-label"><span style="color: red; ">*</span>实际进水量（t/d）：</label>
                <div class="col-sm-8">
                  <input name="actualIntake" class="form-control" th:field="*{designIntake}" type="text" maxlength="8" required>
                </div>
              </div>
            </div>
            <div class="col-sm-12">
              <div class="form-group">
                <label class="col-sm-3 control-label"><span style="color: red; ">*</span>项目金额（元）：</label>
                <div class="col-sm-8">
                  <input name="projectPrice" class="form-control digits" th:field="*{projectPrice}" type="text" maxlength="9" required>
                </div>
              </div>
            </div>
            <div class="col-sm-12">
              <div class="form-group">
                <label class="col-sm-3 control-label"><span style="color: red; ">*</span>技术服务费（元）：</label>
                <div class="col-sm-8">
                  <input name="techPrice" class="form-control digits" th:field="*{techPrice}" type="text" maxlength="9" required>
                </div>
              </div>
            </div>
          </div>
        </form>
      </div>
      <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
          <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
          <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
      </div>
    </div>
  </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: distpicker-js" />
<script type="text/javascript">
  var prefix = ctx + "project/projectInfo";
  $("#form-projectInfo-edit").validate({
    focusCleanup: true
  });

  function submitHandler() {
    if ($.validate.form()) {
      var data = $("#form-projectInfo-edit").serializeArray();
      var _province = $("#province_id  option:selected");
      var _city = $("#city_id  option:selected");
      var _zone = $("#zone_id  option:selected");
      data.push({"name": "provinceId", "value": _province.data('code')});
      data.push({"name": "provinceName", "value": _province.val()});
      data.push({"name": "cityId", "value": _city.data('code')});
      data.push({"name": "cityName", "value": _city.val()});
      data.push({"name": "zoneId", "value": _zone.data('code')});
      data.push({"name": "zoneName", "value": _zone.val()});
      $.ajax({
        url: prefix + "/edit",
        type: "post",
        dataType: "json",
        data: data,
        success: function(result) {
          if (result.code == web_status.SUCCESS) {
            layer.msg(result.msg, { icon: $.modal.icon(modal_status.SUCCESS), time: 1000},function() {
              location.reload();
            });
          } else if (result.code == web_status.WARNING) {
            $.modal.msgWarning(result.msg)
          } else {
            $.modal.msgError(result.msg);
          }
          $.modal.closeLoading();
        }
      });
    }
  }

  function selectDeptTree() {
    var treeId = $("#treeId").val();
    var deptId = $.common.isEmpty(treeId) ? "106" : $("#treeId").val();
    var url = ctx + "system/dept/selectDeptTree/" + deptId;
    var options = {
      title: '选择项目公司名称',
      width: "380",
      url: url,
      callBack: doSubmit
    };
    $.modal.openOptions(options);
  }

  function doSubmit(index, layero){
    var tree = layero.find("iframe")[0].contentWindow.$._tree;
    if ($.tree.notAllowParents(tree)) {
      var body = layer.getChildFrame('body', index);
      $("#treeId").val(body.find('#treeId').val());
      $("#treeName").val(body.find('#treeName').val());
      $("#treeName").valid();
      layer.close(index);
    }
  }
</script>
</body>
</html>
